# 用户界面入口
from .mainframe import MainFrame
from .event_bus import Event, register_handler
from .event_bus import ETYPE_TAG_CHANGED, ETYPE_BOOKMARK_CHANGED
from ..store import commit_store


class BookmarkApp():
    def __init__(self):
        register_handler(self.on_event)
        self.main_frame = MainFrame()

    def on_event(self, evt: Event):
        if evt.t in [ETYPE_TAG_CHANGED, ETYPE_BOOKMARK_CHANGED]:
            # commit if data changed
            commit_store()

    def run(self):
        self.main_frame.mainloop()
